﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

public partial class BalanceCenter_MyProblemList : PageBase
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindData();
        }
    }

    #region Web 窗体设计器生成的代码

    override protected void OnInit(EventArgs e)
    {
        isRequestLogin = true;
        SecondLevelPassword = true;
        RequestLoginPage = "BalanceCenter/MyProblemList.aspx";

        base.OnInit(e);
    }

    #endregion

    private void BindData()
    {
        DataTable dt = DAL.Views.V_MessageBoard.Select("", "[UserID] = " + _User.ID.ToString(), "[DateTime] desc");

        if (dt == null)
        {
            PublicFunction.GoError(ErrorNumber.DataReadWrite, "数据读写错误", this.GetType().BaseType.FullName);

            return;
        }

        dt.Columns.Add("Content2", typeof(System.String));
        dt.Columns.Add("Reply2", typeof(System.String));
        dt.Columns.Add("userName", typeof(System.String));

        for (int i = 0; i < dt.Rows.Count; i++)
        {
            string Content = "", Reply = "";
            try
            {
                Content = ShoveEL._Convert.ToHtmlCode(ShoveEL._String.Decompress((byte[])dt.Rows[i]["Content"]));
            }
            catch
            { }

            try
            {
                Reply = ShoveEL._Convert.ToHtmlCode(ShoveEL._String.Decompress((byte[])dt.Rows[i]["Reply"]));
            }
            catch
            {
            }

            dt.Rows[i]["Content2"] = Content;
            dt.Rows[i]["Reply2"] = (Reply == "") ? "<FONT color='Silver'>暂未回复</FONT>" : Reply;

            if (dt.Rows.Count <= 0)
            {
                return;
            }
            else
            {
                try
                {
                    dt.Rows[i]["userName"] = dt.Rows[i]["ToUserName"];
                }
                catch (Exception ex)
                {
                    string msg = ex.Message;
                }
            }

            dt.AcceptChanges();
        }

        g.DataSource = dt.DefaultView;
        g.DataBind();
    }

    protected void g_PageIndexChanged(object sender, System.EventArgs e)
    {
        g.CurrentPageIndex = ((DataGridPageChangedEventArgs)e).NewPageIndex;
        BindData();
    }
}
